<?php
/**
 * Created by PhpStorm.
 * User: maqun
 * Date: 2016/2/27
 * Time: 16:56
 */
class UsersModel extends BaseModel{

    protected $tableName = "users";//数据库表名

    /**
     * @param $data
     * @return array
     * 修改密码
     */
    public function changePass($data){

        $user_id = $data['user-id'];
        $newpass = $data['pass'];
        $res = $this->field('user_id')->where("user_id='{$user_id}'")->select();

        if(!empty($res)){
            $res = $this->where("user_id='".$res[0]['user_id']."'")->setField('password',md5($newpass));
            $return =  false!==$res ? array('status'=>true,'info'=>'修改成功') : array('status'=>false,'info'=>'修改失败');
        }else{
            $return = array('status'=>false,'登录名不存在');
        }
        return $return;

    }
}